package ch.pizzapp.kurier;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import ch.pizzapp.kurier.data.ResponceData;
import ch.pizzapp.kurier.data.UserResonce;

@EActivity(R.layout.activity_places)
public class PlacesActivity extends FragmentActivity {

	@Extra("ResponceData")
	ResponceData responceData;

	@Extra("UserResonce")
	UserResonce userResonce;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_places);

		if (savedInstanceState == null) {
			getSupportFragmentManager()
					.beginTransaction()
					.add(R.id.container,
							PlaceFragment
									.newInstance(responceData, userResonce))
					.commit();
		}

		getActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
